package com.ht.medicaltreatment.activity

import androidx.activity.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.gym.baselib.base.BaseActivity
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.adapter.ReturnDetailAdapetr
import com.ht.medicaltreatment.viewmodel.ReturnRecordViewModel
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.etProjectName
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.recyclerView
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.tvCount
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.tvEndTime
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.tvRemark
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.tvReturnTime
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.tvStartTime
import kotlinx.android.synthetic.main.activity_return_record_detail_layout.tvUserName

class ReturnOrderDetailActivity:BaseActivity() {
    override fun getLayoutId() = R.layout.activity_return_record_detail_layout
    private val model by viewModels<ReturnRecordViewModel>()

    private val adapter = ReturnDetailAdapetr()
    override fun init() {
        setTitle("表单详情")

        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.adapter = adapter

        val id = intent.getIntExtra("id",-1)
        val projectId = intent.getStringExtra("projectId")
        val orderName = intent.getStringExtra("orderName")
        val startTime = intent.getStringExtra("startTime")
        val endTime = intent.getStringExtra("endTime")
        val userName = intent.getStringExtra("userName")
        val remark = intent.getStringExtra("remark")
        val returnTime = intent.getStringExtra("returnTime")

        etProjectName.text = orderName
        tvStartTime.text = startTime
        tvEndTime.text = endTime
        tvRemark.text = remark
        tvUserName.text = userName
        tvReturnTime.text = returnTime

        showProgress()
        model.returnOrderDetail(id,projectId?:"",{
            dismissProgress()
            adapter.setNewInstance(it)
            tvCount.text = "${it?.size}"
        })
    }
}
